package ${table.fileTemplates.controller.filePackage};

import com.framework.mybatis.service.BaseService;
import org.springframework.beans.factory.annotation.Autowired;

public abstract class CrudController<E extends Serializable,S extends BaseService> {

    @Autowired
    private S  baseService;

    @PostMapping
    public E save(E e) {
        baseService.save(e);
        log.debug("保存-{}", e);
        return e;
    }


    @GetMapping("{id}")
    public E detail(@PathVariable("id") Serializable id) {
        E e = baseService.getById(id);
        return e;
    }

    @DeleteMapping("{id}")
    public void delete(@PathVariable("id") Serializable id) {
        baseService.removeById(id);
        log.debug("删除-{}", id);
    }


    @PostMapping
    public E update(E e) {
        baseService.updateById(e);
        log.debug("修改-{}", e);
        return e;
    }

}
